Trò chơi game bắn súng đơn giản trong UNITY Engine
23.578 lượt xem;
1 using UnityEngine;
2 using System.Collections;
3
4 public static class Extensions
5 {
6 public static int Randomization_1(this Random rand, params int[] randBorders)
7 {
8 int r = Random.Range(0,100);
9 int returningValue = 0;
10
11 for (int i = 0; i < randBorders.Length-1; i++)
12 {
13 if (r > randBorders[i] && r < randBorders[i + 1])
14 {
15 returningValue = i;
16 break;
17 }
18 }
19
20 return returningValue;
21 }
22
23 public static int Randomization_2(this Random rand, params int[] digits)
24 {
25 return Random.Range(0, digits.Length);
26 }
27 }
28
29 public enum BonusesEnum
30 {
31 bonusHealth = 0,
32 bonusMoney = 1,
33 bonusSpeed = 2,
34 bonusBullet = 3
35 }
36
37 interface IInterractWithBullet
38 {
39 void GetDamage(int damage = 1);
40 void Die();
41 }
42
43 public class SystemScr : MonoBehaviour
44 {
45 public static bool mute;
46 public static bool paused;
47 public static bool difficultyIsHard;//changes maximum score, enemy`s life, spawning frequency
48
49 void Start ()
50 {
51 paused = false;
52 }
53
54 public static void Pause(bool onPause)
55 {
56 if (onPause)
57 {
58 Time.timeScale = 0;
59 paused = true;
60 }
61 else
62 {
63 Time.timeScale = 1;
64 paused = false;
65 }
66 }
67 }
2 using System.Collections;
3
4 public static class Extensions
5 {
6 public static int Randomization_1(this Random rand, params int[] randBorders)
7 {
8 int r = Random.Range(0,100);
9 int returningValue = 0;
10
11 for (int i = 0; i < randBorders.Length-1; i++)
12 {
13 if (r > randBorders[i] && r < randBorders[i + 1])
14 {
15 returningValue = i;
16 break;
17 }
18 }
19
20 return returningValue;
21 }
22
23 public static int Randomization_2(this Random rand, params int[] digits)
24 {
25 return Random.Range(0, digits.Length);
26 }
27 }
28
29 public enum BonusesEnum
30 {
31 bonusHealth = 0,
32 bonusMoney = 1,
33 bonusSpeed = 2,
34 bonusBullet = 3
35 }
36
37 interface IInterractWithBullet
38 {
39 void GetDamage(int damage = 1);
40 void Die();
41 }
42
43 public class SystemScr : MonoBehaviour
44 {
45 public static bool mute;
46 public static bool paused;
47 public static bool difficultyIsHard;//changes maximum score, enemy`s life, spawning frequency
48
49 void Start ()
50 {
51 paused = false;
52 }
53
54 public static void Pause(bool onPause)
55 {
56 if (onPause)
57 {
58 Time.timeScale = 0;
59 paused = true;
60 }
61 else
62 {
63 Time.timeScale = 1;
64 paused = false;
65 }
66 }
67 }
public static bool difficultyIsHard;changes maximum score, enemy`s life, spawning frequency